package kr.hkit.androidcomplete01.chaptert08;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Toast;

public class HandleOrder extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		MyView vm = new MyView(this);
		vm.setOnTouchListener(new OnTouchListener() {
			
			public boolean onTouch(View v, MotionEvent event) {
				if(event.getAction() == MotionEvent.ACTION_DOWN){
					Toast.makeText(getApplicationContext(), "Listener : touchEvent Received", Toast.LENGTH_SHORT).show();
					return true;
				}
				return false;
			}
		});
		setContentView(vm);
	}
	
	
	
	@Override
	public boolean onTouchEvent(MotionEvent event) {
		super.onTouchEvent(event);
		if(event.getAction() == MotionEvent.ACTION_DOWN){
			Toast.makeText(getApplicationContext(), "Activity : touchEvent Received", Toast.LENGTH_SHORT).show();
			return true;
		}
		return false;
	}



	class MyView extends View {

		public MyView(Context context) {
			super(context);
		}

		@Override
		public boolean onTouchEvent(MotionEvent event) {
			super.onTouchEvent(event);
			if(event.getAction() == MotionEvent.ACTION_DOWN){
				Toast.makeText(getApplicationContext(), "View : touchEvent Received", Toast.LENGTH_SHORT).show();
				return true;
			}
			return false;
		}
		
		
	}
}
